import gevent
import time
from gevent import monkey
import random

monkey.patch_all()  # 将程序中用到的耗时操作的代码，换位gevent中自己实现的模块

def corountine_work(corountine_name):
    for i in range(10):
        print(corountine_name, i)
        time.sleep(random.random())


gevent.joinall([
    gevent.spawn(corountine_work, "work1"),
    gevent.spawn(corountine_work, "work2"),
    gevent.spawn(corountine_work, "work3")
])
